package com.example.demo.send;

import com.example.demo.config.RabbitMqConfig;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.rabbit.support.CorrelationData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class FirstSender {

    @Autowired
    private RabbitTemplate template;

    /**
     * 发送消息
     * @param uuid
     * @param msg
     */
    public void sendMsg(String uuid ,Object msg){
        CorrelationData correlationId = new CorrelationData(uuid);
        template.convertAndSend(RabbitMqConfig.EXCHANGE, RabbitMqConfig.ROUTINGKEY2,
                msg, correlationId);
    }
}
